using System;
using System.Collections.Generic;
using System.Linq;
using GalaSoft.MvvmLight;
using Locator.Silverlight.Client.Models.InventoryServiceReference;

namespace Locator.Silverlight.Client.Models.ViewModels.Elements
{
    public class InventoryInfoViewModel : ViewModelBase
    {
        private readonly InventoryInfo inventoryInfo;
        private readonly ProductViewModel product;

        public InventoryInfoViewModel(InventoryInfo inventoryInfo)
        {
            this.inventoryInfo = inventoryInfo;
            if (this.inventoryInfo.Product == null)
            {
                throw new ArgumentNullException("inventoryInfo.Product", "The inventoryInfo's Product object is null");
            }
            else
            {
                this.product = new ProductViewModel() { Id = this.inventoryInfo.Product.Id, Name = this.inventoryInfo.Product.Name };
            }
        }

        public int NumberInStock
        {
            get { return this.inventoryInfo.NumberInStock; }
        }

        public ProductViewModel Product
        {
            get { return this.product; }
        }
    }
}